program mynormal2, sortpreserve
	version 8.1
	if replay() {
		if (`"`e(cmd)'"' != "mynormal2") error 301
		Replay `0'
	}
	else	Estimate `0'
end

program Estimate, eclass
	syntax varlist [if] [in] [,		///
		Robust				///
		CLuster(varname)		/// <- NEW
		HETero(varlist)			/// <- NEW
		Level(integer `c(level)')	/// -Replay- option
	]

	// check syntax
	gettoken lhs rhs : varlist
	if "`cluster'" != "" {				// NEW block
		local clopt cluster(`cluster')
	}
	// mark the estimation sample
	marksample touse

	// fit the full model
	ml model d2 mynormal_d2				///
		(mu: `lhs' = `rhs')			///
		(lnsigma: `hetero')			/// <- NEW
		if `touse',				///
		`robust'				///
		`clopt'					/// <- NEW
		maximize

	ereturn local cmd mynormal2

	Replay , level(`level')
end

program Replay
	syntax [, Level(integer `c(level)') ]
	ml display , level(`level')
end
